<%@page import="classes.Courses"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import ="readFromDB.GetStudent" %>
<%@ page import ="java.util.List" %>
<%@ page import ="classes.Students" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询课程</title>


<%	String ID=String.valueOf((request.getSession().getAttribute("ID"))); %>
<h1 align="center">欢迎管理员： <%=ID%></h1>
<title>查找学生</title>
<script>
	function check(){
		var condi = document.getElementByName("condition");
		if(codi==""|condi=="null"){
			alert("搜索条件不能为空");
			return false;
		}
	}

</script>

<div align="left">
	<ul>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/admin_home.jsp">返回主页</a></li>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/look_student.jsp">查看学生信息</a></li>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/look_course.jsp">查看课程信息</a></li>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/add_student.jsp">新增学生信息</a></li>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/add_course.jsp">新增课程信息</a></li>
		<li><a href="http://localhost:8080/my_term_project_xuanke/admin/select_course.jsp">查找已有课程</a></li>	
	</ul>
</div>
</head>

<body>
	<%
    String url="http://localhost:8080/my_term_project_xuanke/adminServlet?action=select_students";
      %> 
 <form name="select_students" action="<%=url%>" method="post" onsubmit="return check()">
<div align="center">	
	<select name="select_students">
		<option value="sno">学号</option>
		<option value="profess">专业</option>
		<option value="grade">年级</option>
		<option value="cno">课程编号</option>
	</select>
	<input type="text" name="condition" value="20"/>
	<input type="submit"  value="查询"/>
 </div>
 <p align="center">查询结果如下</p>    
 </form> 
 
              
<table border="1" align="center">
       <tr>
         <th>学号</th>
         <th>姓名</th>
         <th>年级</th>
         <th>专业</th>
         <th>学院</th>
		 <th>密码</th>
		 <th>手机号码</th>		
		 <th>已修课程</th>	
		 <th>修改</th> 
		 <th>删除</th> 	 
       </tr>
        <%

        List<Students> list =(List<Students>)request.getSession().getAttribute("select_students_result");  
        String error="查询结果为空";
        List<Students> flushList=null;
        request.getSession().setAttribute("select_students_result",flushList);
       if(list!=null){    
           for(Students student:list)
           {%>
         <tr>
              <td><%=student.getStuId() %></td>
              <td><%=student.getStuName() %></td>
              <td><%=student.getStuGrage()  %></td>
              <td><%=student.getStuProfess() %></td>
              <td><%=student.getStuInstitute()  %></td>
              <td><%=student.getStuPwd() %></td>     
              <td><%=student.getStuPhhone() %></td>
              <td><%=student.getStuCourselearned() %></td> 
              <%
              String alter_url="http://localhost:8080/my_term_project_xuanke/admin/alter_student.jsp?Sno=";
              String stuID=student.getStuId();
              String alter=alter_url+stuID;
              String serveletUrl="http://localhost:8080/my_term_project_xuanke/adminServlet?";
              String delete=serveletUrl+"action=delete_student&Sno="+stuID;
              %> 
              <td><a href="<%=alter%>"><input type="button"  value="修改"/></a></td>
              <td><a href="<%=delete%>"><input type="button"  value="删除"/></a></td>
           </tr>
             <%} %> 
          
          <%  }
       if(list==null){
       		%>
      <div>
      	 <p  align="center"><%=error%><p>
     </div>
     
       <%
       
       }
      %>
    </table>   
</body>
</html>